home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / os2 / adaptor.zip / ADAPT.ZIP / adaptor / dalib / pvm3 / combiner.c < prev    next >
C/C++ Source or Header  |  1993-06-09  |  4KB  |  154 lines

  1. /*******************************************************************
  2. *                                                                  *
  3. *  MODULE : combiners.c                                            *
  4. *                                                                  *
  5. *  Function:   Actual parameter functions for reductions/scatters  *
  6. *                                                                  *
  7. *******************************************************************/
  8.  
  9. void or_bools (i1, i2)   /* .OR., ANY */
  10. int *i1, *i2;
  11. { if (*i2) *i1 = *i2;
  12. }
  13.  
  14. void and_bools (i1, i2)  /* .AND., ALL */
  15. int *i1, *i2;
  16. { if (!(*i2)) *i1 = *i2;
  17. }
  18.  
  19. void neq_bools (i1, i2)   /* .NEQV., PARITY */
  20. int *i1, *i2;
  21. { if (*i2) *i1 = !(*i1);
  22. }
  23.  
  24. void add_ints (i1, i2)   /* +, SUM, COUNT */
  25. int *i1, *i2;
  26. { *i1 = *i1 + *i2;
  27. }
  28.  
  29. void mult_ints (i1, i2)   /* *, PRODUCT */
  30. int *i1, *i2;
  31. { *i1 = *i1 * *i2;
  32. }
  33.  
  34. void max_ints (i1, i2)    /* max, MAXVAL */
  35. int *i1, *i2;
  36. { if (*i2 > *i1) *i1 = *i2; }
  37.  
  38. void min_ints (i1, i2)    /* min, MINVAL */
  39. int *i1, *i2;
  40. { if (*i2 < *i1) *i1 = *i2; }
  41.  
  42. void and_ints (i1, i2)   /* IAND, AND */
  43. int *i1, *i2;
  44. { *i1 = *i1 & *i2;
  45. }
  46.  
  47. void or_ints (i1, i2)   /* IOR, OR */
  48. int *i1, *i2;
  49. { *i1 = *i1 | *i2;
  50. }
  51.  
  52. void eor_ints (i1, i2)   /* IEOR, EOR */
  53. int *i1, *i2;
  54. { *i1 = *i1 ^ *i2;
  55. }
  56.  
  57. void add_reals (f1, f2)   /* +, SUM */
  58. float *f1, *f2;
  59. { *f1 = *f1 + *f2; }
  60.  
  61. void mult_reals (f1, f2)   /* *, PRODUCT */
  62. float *f1, *f2;
  63. { *f1 = *f1 * *f2; }
  64.  
  65. void max_reals (f1, f2)    /* MAX, MAXVAL */
  66. float *f1, *f2;
  67. { if (*f2 > *f1) *f1 = *f2; }
  68.  
  69. void min_reals (f1, f2)    /* MIN, MINVAL */
  70. float *f1, *f2;
  71. { if (*f2 < *f1) *f1 = *f2; }
  72.  
  73. void add_doubles (f1, f2)    /* +, SUM */
  74. double *f1, *f2;
  75. { *f1 = *f1 + *f2; }
  76.  
  77. void mult_doubles (f1, f2)   /* *, PRODUCT */
  78. double *f1, *f2;
  79. { *f1 = *f1 * *f2; }
  80.  
  81. void max_doubles (f1, f2)    /* MAX, MAXVAL */
  82. double *f1, *f2;
  83. { if (*f2 > *f1) *f1 = *f2; }
  84.  
  85. void min_doubles (f1, f2)    /* MIN, MINVAL */
  86. double *f1, *f2;
  87. { if (*f2 < *f1) *f1 = *f2; }
  88.  
  89. void add_complexes (f1, f2)    /* +, SUM */
  90. float f1[2], f2[2];
  91. { f1[0] = f1[0] + f2[0];  
  92.   f1[1] = f1[1] + f2[1]; }
  93.  
  94. /*******************************************************************
  95. *                                                                  *
  96. *  reduction functions with saving position                        *
  97. *                                                                  *
  98. *******************************************************************/
  99.  
  100. void max_pos_ints (p1, p2, f1, f2)    /* MAX, MAXLOC */
  101. int *p1, *p2;
  102. int *f1, *f2;
  103. { if (*f2 > *f1)
  104.      { *f1 = *f2; 
  105.        *p1 = *p2;
  106.      }
  107. }
  108.  
  109. void min_pos_ints (p1, p2, f1, f2)    /* MIN, MINLOC */
  110. int *p1, *p2;
  111. int *f1, *f2;
  112. { if (*f2 < *f1)
  113.      { *f1 = *f2; 
  114.        *p1 = *p2;
  115.      }
  116. }
  117.  
  118. void max_pos_reals (p1, p2, f1, f2)    /* MAX, MAXLOC */
  119. int *p1, *p2;
  120. float *f1, *f2;
  121. { if (*f2 > *f1) 
  122.      { *f1 = *f2; 
  123.        *p1 = *p2;
  124.      }
  125. }
  126.  
  127. void min_pos_reals (p1, p2, f1, f2)    /* MIN, MINLOC */
  128. int *p1, *p2;
  129. float *f1, *f2;
  130. { if (*f2 < *f1)
  131.      { *f1 = *f2; 
  132.        *p1 = *p2;
  133.      }
  134. }
  135.  
  136. void max_pos_doubles (p1, p2, f1, f2)    /* MAX, MAXLOC */
  137. int *p1, *p2;
  138. double *f1, *f2;
  139. { if (*f2 > *f1)
  140.      { *f1 = *f2; 
  141.        *p1 = *p2;
  142.      }
  143. }
  144.  
  145. void min_pos_doubles (p1, p2, f1, f2)    /* MIN, MINLOC */
  146. int *p1, *p2;
  147. double *f1, *f2;
  148. { if (*f2 < *f1) 
  149.      { *f1 = *f2; 
  150.        *p1 = *p2;
  151.      }
  152. }
  153.  
  154.